package com.example.demoa;

import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.btu_1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                //显示Intent的运用
//                intent.setClass(MainActivity.this,StudentActivity.class);

//                String packageName = "com.example.demoa";
//                String className = "com.example.demoa.StudentActivity";
//                intent.setClassName(packageName,className);

                String className = "com.example.demoa.StudentActivity";
                intent.setClassName(MainActivity.this, className);

                startActivity(intent);
            }
        });

        findViewById(R.id.btu_2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //隐示Intent的运用
                Intent intent = new Intent();

                //打开http://www.baidu.com
                intent.setAction(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("http://www.baidu.com"));

                //打开地图位置
//                intent.setAction(Intent.ACTION_VIEW);
//                intent.setData(Uri.parse("geo:23.1890030000，113.3596550000"));

                startActivity(intent);

            }
        });

        findViewById(R.id.btu_3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //隐示Intent的运用
                Intent intent = new Intent();

                //打开StudentActivity
//                intent.setAction("VIEW_STUDENT");

                intent.setAction("I_WANT_EAT");
                intent.addCategory("NIO_ROU_FAN");

                startActivity(intent);

            }
        });
    }
}